<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美育儿</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/static/admin/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/admin/plugins/font-awesome/css/font-awesome.min.css">

</head>

<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header header-demo">
        <div class="layui-main">
            <div class="admin-login-box">
                <a class="logo" style="left: 0;" href="\">
                    <span style="font-size: 22px;">美育儿后台</span>
                </a>
                <div class="admin-side-toggle">
                    <i class="fa fa-bars" aria-hidden="true"></i>
                </div>
            </div>
            <ul class="layui-nav admin-header-item">

                <li class="layui-nav-item">
                    <a href="javascript:;" class="admin-header-user">
                        <img src="/static/admin/images/0.jpg"/>
                        <span>{$userName}</span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a href="javascript:void(0)" id="updatePwd"><i class="fa fa-gear" aria-hidden="true"></i>
                                修改密码</a>
                        </dd>
                        <dd id="lock">
                            <a href="javascript:;">
                                <i class="fa fa-lock" aria-hidden="true"
                                   style="padding-right: 3px;padding-left: 1px;"></i> 锁屏 (Alt+L)
                            </a>
                        </dd>
                        <dd>
                            <a href="javascript:void(0)" id="logout"><i class="fa fa-sign-out" aria-hidden="true"></i> 注销</a>
                        </dd>
                    </dl>
                </li>
            </ul>
            <ul class="layui-nav admin-header-item-mobile">
                <li class="layui-nav-item">
                    <a href="login.html"><i class="fa fa-sign-out" aria-hidden="true"></i> 注销</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="layui-side layui-bg-black" id="admin-side">
        <div class="layui-side-scroll" id="admin-navbar-side" lay-filter="side"></div>
    </div>
    <div class="layui-body" style="bottom: 0;border-left: solid 2px #1AA094;" id="admin-body">
        <div class="layui-tab admin-nav-card layui-tab-brief" lay-filter="admin-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">
                    <i class="fa fa-dashboard" aria-hidden="true"></i>
                    <cite>首页</cite>
                </li>
            </ul>
            <div class="layui-tab-content" style="min-height: 150px; padding: 5px 0 0 0;">
                <div class="layui-tab-item layui-show">
                    <iframe src="/index/main.html"></iframe>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-footer footer footer-demo" id="admin-footer">
        <div class="layui-main">
            <p>2017 &copy;
                <a href="javascript:void(0);" target="_blank">每育儿</a>
            </p>
        </div>
    </div>
    <div class="site-tree-mobile layui-hide">
        <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>

    <!--锁屏模板 start-->
    <script type="text/template" id="lock-temp">
        <div class="admin-header-lock" id="lock-box">
            <div class="admin-header-lock-img">
                <img src="/static/admin/images/0.jpg"/>
            </div>
            <div class="admin-header-lock-name" id="lockUserName">{$userName}</div>
            <input type="text" class="admin-header-lock-input" value="输入密码解锁.." name="lockPwd" id="lockPwd"/>
            <button class="layui-btn layui-btn-small" id="unlock">解锁</button>
        </div>
    </script>
    <!--锁屏模板 end -->
    <script type="text/javascript" src="/static/admin/plugins/layui/layui.js"></script>
    <!--<script type="text/javascript" src="/shop/index/menu"></script>-->
    <script src="/static/admin/js/index.js"></script>
    <script type='text/javascript' src='/static/admin/plugins/hx/webim.config.js'></script>
    <script type='text/javascript' src='/static/admin/plugins/hx/strophe-1.2.8.min.js'></script>
    <script type='text/javascript' src='/static/admin/plugins/hx/websdk-1.4.10.js'></script>
    <script>
        var $;
        layui.use('layer', function () {
            $ = layui.jquery,
                    layer = layui.layer;

            $('#updatePwd').click(function () {
                var content = "<form class='layui-form' style='margin-top:30px;'>"
                        +"<div class='layui-form-item'><label class='layui-form-label'>密码</label><div class='layui-input-inline'><input type='password' id='password1' placeholder='请输入密码' autocomplete='off' class='layui-input'></div><div class='layui-form-mid layui-word-aux'>长度6~16位</div></div>"
                        +"<div class='layui-form-item'><label class='layui-form-label'>再输一次</label><div class='layui-input-inline'><input type='password' id='password2' placeholder='请输入密码' autocomplete='off' class='layui-input'></div><div class='layui-form-mid layui-word-aux'>长度6~16位</div></div>"
                        +"</form>";
                layer.open({
                    type: 1,
                    title: '修改密码',
                    content: content,
                    btn: ['保存', '取消'],
                    area: ['600px', '400px'],
                    maxmin: true,
                    yes: function (index) {
                        $.ajax({
                            type: "POST",
                            url: '/manager/resetPwd',
                            data:  {'password1':$('#password1').val(),'password2':$('#password2').val()},
                            async: true,
                            beforeSend: function () {
                                jz = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
                            },
                            error: function (request) {
                                layer.close(jz);
                                layer.alert('网络错误',{icon:2}, function(index){
                                    layer.close(index);
                                });
                            },
                            success: function (data) {
                                //关闭加载层
                                layer.close(jz);
                                if (data.code == 1) {
                                    layer.msg(data.msg, {
                                        icon: 1,
                                        time: 1500
                                    }, function(){
                                        window.location.href = data.data.url;
                                    });
                                } else if(data.code == -1){
                                    window.location.href = '/login/login';
                                }else {
                                    layer.alert(data.msg);
                                }
                            }
                        });
                    }
                });
            });

            $('#logout').click(function(){
                $.ajax({
                    type: "GET",
                    url: '/login/logout',
                    async: true,
                    beforeSend: function () {
                        jz = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
                    },
                    error: function (request) {
                        layer.close(jz);
                        layer.alert('网络错误',{icon:2}, function(index){
                            layer.close(index);
                        });
                    },
                    success: function (data) {
                        //关闭加载层
                        layer.close(jz);
                        if (data.code == 1) {
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 1500
                            }, function(){
                                window.location.href = data.data.url;
                            });
                        } else if(data.code == -1){
                            window.location.href = '/login/index';
                        }else {
                            layer.alert(data.msg);
                        }
                    }
                });
            });
        });
    </script>
</div>
</body>

</html>
